package com.duanjw.java.map;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class MyMapTest {
    public static void main(String[] args) {
        MyMap myMap = new MyHashMyMap<>();
        for (int i = 0; i < 2000000; i++) {
            myMap.put("张" + i, "i");
        }
        long startTime = System.nanoTime();
        myMap.get("张88888");
        long endTime = System.nanoTime();
        System.out.println("自定义hashmap调用get方法用时：" + (endTime - startTime));

        TimeUnit.NANOSECONDS.compareTo(TimeUnit.NANOSECONDS);

        Map<String, String> map = new HashMap<>();

        for (int i = 0; i < 2000000; i++) {
            map.put("李" + i, "i");
        }
        long startTime1 = System.nanoTime();
        map.get("李88888");
        long endTime1 = System.nanoTime();
        System.out.println("jdk hashmap调用get方法用时：" + (endTime1 - startTime1));
//        System.out.println(new MyMapTest().find(0));
    }

    public int find(int i) {
        if(++i!=20000){
            return find(i);
        }
        return 0;
    }
}
